/**
 * Created by user on 2018/11/19.
 */
'use strict';

module.exports = app => {

    const { STRING, INTEGER } = app.Sequelize;

    const UserToken = app.model.define('user_token',
        {
            id: { type: INTEGER, primaryKey: true, autoIncrement: true },
            token: STRING(255),
            user_id: INTEGER,
            update_at: STRING(255)
        },
        {
            freezeTableName: true, // Model 对应的表名将与model名相同
            timestamps: false
        }
    )
    UserToken.associate = function() {
        app.model.UserToken.belongsTo(app.model.User, {foreignKey:'user_id', targetKey: 'id'});
    }

    return UserToken;
};